package com.company.nuwa.common.constants;

import java.text.MessageFormat;

import com.company.nuwa.common.enumration.TerminalTypeEnum;
import com.company.nuwa.common.key.ApplicationNamedKeyGenerator;

import lombok.extern.slf4j.Slf4j;

/**
 * <p>用户登录token</p>
 *
 * @author lili
 * @version 1.0: JwtTokenCacheKeys.java
 * @date 2024/2/2 13:47
 */
@Slf4j
public class JwtTokenCacheKeys {

    public static final int TOKEN_DEFAULT_EXPIRES_DAYS = 7;

    /**
     * 用户登录token
     * @param userId 用户id
     * @param terminalType  终端类型
     * @return String
     */
    public static String getUserTokenKey(Long userId, TerminalTypeEnum terminalType) {
        return ApplicationNamedKeyGenerator.genKey(true, MessageFormat
            .format("USER_JWT_TOKEN:{0}:{1}", terminalType.getType(), String.valueOf(userId)));
    }

}
